package org.sandbox2.domain.invoice;

import java.util.Date;

import org.sandbox2.util.CalendarUtil;

public class DelinquentInvoiceSpecification extends InvoiceSpecification {

	private Date currentDate;
	
	public DelinquentInvoiceSpecification(Date currentDate) {
		this.currentDate = currentDate;
	}
	
	
	@Override
	protected Boolean isSatisfiedBy(Invoice candidate) {

		int gracePeriod = candidate.getPaymentGracePeriod();
		
		Date firmDeadLine = CalendarUtil.addDate(candidate.getDueDate(), gracePeriod);
		return currentDate.after(firmDeadLine);

	}
}
